import Home from '../../views/Home.vue'
const routers = [
  {
    path: '/',
    name: 'Home',
    component: "Home"
  },
  {
    path:"/journal/post",
    name:"Postlog",
    component:"journal/Postlog"
  },
  {
    path:"/journal/administration",
    name:"logs",
    component:"journal/Logs"
  },
  {
    path:"/login",
    name:"Logs",
    component:"Login"
  },
  {
    path:"/user/information",
    name:"Information",
    component:"user/Information"
  },
  {
    path:"/album/CoverManage",
    name:"albumCover",
    component:"album/cover/CoverManage"
  },
  {
    path:"/album/CoverPublish",
    name:"albumPublish",
    component:"album/cover/CoverPublish"
  },
  {
    path:"/album/DynamicPublish",
    name:"DynamicPublish",
    component:"album/dynamic/DynamicPublish"
  },
  {
    path:"/album/DynamicManage",
    name:"DynamicManage",
    component:"album/dynamic/DynamicManage"
  },
  {
    path:"/album/StaticManage",
    name:"StaticManage",
    component:"album/static/StaticManage"
  },
  {
    path:"/album/StaticPublish",
    name:"StaticPublish",
    component:"album/static/StaticPublish"
  },
  {
    path:"/user/power",
    name:"userPower",
    component:"user/Jurisdiction"
  },
  {
    path:"/Personal",
    name:"Personal",
    component:"Personal"
  },
  {
    path:"/user/add",
    name:"Addadministrator",
    component:"user/Addadministrator"
  },
  {
    path:"/user/user",
    name:"userMannzge",
    component:"user/userManage"
  },
  {
    path:"/share/publish",
    name:"SharePublish",
    component:"share/SharePublish"
  },
  {
    path:"/share/manage",
    name:"ShareManage",
    component:"share/ShareManage"
  },
  {
    path:"/message/manage",
    name:"messageManage",
    component:"message/MessageManage"
  }
]

// 获取路由信息方法
let getRoutes = function(){
  // 生成路由详细信息
  createRoute(routers)
  return routers
}

// 自动生成路由
function createRoute(arr){
  for(let i=0;i<arr.length;i++){
    if(!arr[i].component) return
    // 自动生成component
    let componentFun = import(`../../views/${arr[i].component}.vue`)
    arr[i].component = ()=>componentFun
    // 遍历子路由
    if(arr[i].children && arr[i].children.length>0 ){
      createRoute(arr[i].children)
    }
  }
}

// 导出数组
export default getRoutes()